package den.Study_2;

public class DoubleLink {
	private DoubleLink next;
	private Object object;
	

	/**
	 * @return the next
	 */
	public DoubleLink getNext() {
		return next;
	}


	/**
	 * @param next the next to set
	 */
	public void setNext(DoubleLink next) {
		this.next = next;
	}


	/**
	 * @return the object
	 */
	public Object getObject() {
		return object;
	}


	/**
	 * @param object the object to set
	 */
	public void setObject(Object object) {
		this.object = object;
		//System.out.println("aaaaaaaaa");
	}
	
	
	public DoubleLink next(){
		return next;
	}
	
	
	public boolean hasNext(){
		return next.next()!=null;
	}
	
	
	public DoubleLink setNull(){
		return next=null;
	}
	public void insert(DoubleLink v,int index){
		DoubleLink object=null;
		//DoubleLink dl_1=next.getObject(index);
		next=next.getObject(index);
		if(next.hasNext()){
			next=next.next();
		}
		object=next;
		next=v;
		next.setObject(v.getObject());
		next.setNull();
		
	}
	public void delete(int index){
		int i=index;
		next=next.getObject(i);
		next=null;
	}
	public DoubleLink getObject(int index){
		//System.out.println("aaaaaaaaa");
		
		
		for(int i=1;i<index;i++){
			next=next.next();
			
		}
		return next;
	}
	public static void outPut(Object object){
		System.out.println(object);
	}


	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		DoubleLink dl=new DoubleLink();
		for(int i=0;i<10;i++){
			dl.setObject(i);
		}
		//dl.getObject(5);
		outPut(dl.getObject(5));
		//dl.delete(5);
		//outPut(dl);
	}

}
